#include "MaterialManager.h"
#include <stdio.h>

MaterialManager::MaterialManager()
{
	head = NULL;
}
MaterialManager::~MaterialManager()
{
	if(head)
		head->Remove();
}
void MaterialManager::Add(Material * material)
{
	head = new List<Material>(material, head);
}

Material * MaterialManager::GetMaterial(int index)
{
	List<Material> * search = head;
	int i = 0;
	while(search)
	{
		if(i == index)
			return search->payload;
		i++;
		search = search->next;
	}	
	return NULL;
}

int MaterialManager::GetMaterialIndex(char * name)
{
	List<Material> * search = head;
	int i = 0;
	while(search)
	{
		if(strcmp(name, search->payload->name) == 0)
			return i;
		i++;
		search = search->next;
	}	
	return -1;
}
